/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');
const common=require('./common.js');

// Schema 结构
var UserinfoSchema = new mongoose.Schema({
    uiid      :{type:Number,index: true},//uiid
    uid      :{type:Number,index: true},//uid
    imgurl  :{type:String,default: '/up/images/head/head.png'},//头像路径
    nickname : {type:String,default:"书友"+common.getTimes(new Date().getTime(),"NONE")},
    month     :{type:Number},//月票
    recomm    :{"nan":{type:Number},"nv":{type:Number}},//推荐票
    account    :{type : Number},//起点币
    away  :{type : Number},//赠送币
    userLevel  :{type : Number},//会员等级
    expLevel  :{type : Number},//经验
    level  :{type : Number},//经验等级
    desc  :{type : String,default:"暂无用户简介"}//简介
});

UserinfoSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Userinfo').find(obj, callback).sort(obj1);
};
UserinfoSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Userinfo').findOne(obj).sort(obj1).exec(callback);
};
UserinfoSchema.statics.updateFn = function(obj,obj1,callback) {
    return this.model('Userinfo').update(obj,obj1).exec(callback);
};

var UserinfoModel = db.model('Userinfo', UserinfoSchema);

module.exports=UserinfoModel;